package com.chc.web.borrow.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chc.web.borrow.entity.Borrow;
import com.chc.web.borrow.entity.BorrowParm;
import com.chc.web.borrow.mapper.BorrowMapper;
import com.chc.web.borrow.service.BorrowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA
 *
 * @Author: chc
 * @Date: 2022/04/22/17:43
 * @Description:
 */
@Service
public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> implements BorrowService{
    @Autowired
    private BorrowMapper borrowMapper;

    @Override
    public int addBorrow(List<Borrow> borrow) {
        return borrowMapper.addBorrow(borrow);
    }

    @Override
    public IPage<BorrowParm> getBorrowLook(BorrowParm parm) {
        //构造分页对象
        IPage<BorrowParm> page = new Page<>();
        page.setCurrent(parm.getCurrentPage());
        page.setSize(parm.getPageSize());
        return borrowMapper.getBorrowLook(page,parm.getId(),parm.getCardid(),parm.getReaderName(),parm.getBookName(),parm.getState());
    }

    @Override
    public IPage<BorrowParm> getReturnBook(BorrowParm parm) {
        //构造分页对象
        IPage<BorrowParm> page = new Page<>();
        page.setCurrent(parm.getCurrentPage());
        page.setSize(parm.getPageSize());
        return borrowMapper.getReturnBook(page,parm.getCardid(),parm.getReaderName(),parm.getBookName(),parm.getState());
    }

}
